package com.log.controller;

import com.log.common.vo.ResultVo;
import com.log.service.LogOutService;
import io.swagger.annotations.*;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @auhthor xb
 * @create 2023/10/16
 **/

/*
 出库控制类
 */
@RestController
@CrossOrigin //允许跨域请求
@RequestMapping("/logout")
@Api(tags = "运输管理",value = "")
public class LogGoodsoutController {
    @Resource
    LogOutService logOutService;


    @ApiOperation("派送订单接⼝")
    @ApiImplicitParams({
            @ApiImplicitParam(dataType = "string",name = "name", value =
                    "司机名字",required = true),
            @ApiImplicitParam(dataType = "int",name = "logCarId", value =
                    "车辆编号",required = true),
            @ApiImplicitParam(dataType = "int",name = "logGoodsOutId", value =
                    "出库单编号",required = true),

    })

    @GetMapping("/dispatchorders")
    public ResultVo dispatchOrders(String name,int logCarId,int logGoodsOutId){
        return logOutService.dispatchGoods(name,logCarId,logGoodsOutId);
    }


    @ApiOperation("查看所有历史记录接⼝")
    @GetMapping("/findAlldispatchorders")
    //前端获取总页数，调用data.getPage() status=1，2
    public ResultVo findAlldispatchorders(@RequestParam(defaultValue = "1")int pageNum , @RequestParam(defaultValue = "8") int pageSize){

        return logOutService.finddispatchGoods(pageNum,pageSize);
    }
    //出库接口
    @ApiOperation("出库接口")
    @ApiResponses({
            @ApiResponse(code = 10000, message = "派单接口状态码，描述：出库成功"),
            @ApiResponse(code = 10001, message = "派单接口状态码 ，描述：出库失败")
    })
    @ApiImplicitParam(dataType = "int",name = "logGoodsOutId", value =
            "库品ID",required = true)
    @GetMapping("/outGoods")
    public  ResultVo outGoods(int logGoodsOutId){
        return logOutService.outGoods(logGoodsOutId);
    }
    //根据仓库，查找所有已经出库的商品
    @ApiOperation("查找所有已经出库库品出库接⼝")
    @ApiImplicitParams({
            @ApiImplicitParam(dataType = "int",name = "pageNum", value =
                    "页号",required = true),
            @ApiImplicitParam(dataType = "int",name = "pageSize", value =
                    "每页数量",required = true),
            @ApiImplicitParam(dataType = "int",name = "logGoodsOutDepot", value =
                    "对应仓库",required = true)
    })
    @GetMapping("/findAllOutGoods")
    public ResultVo findAllOutGoods(@RequestParam(defaultValue = "1")int pageNum , @RequestParam(defaultValue = "8") int pageSize,String logGoodsOutDepot){
        return logOutService.findAllOutGoods(pageNum,pageSize,logGoodsOutDepot);
    }
    /*
    运输到达接口
     */
    @ApiOperation("商品到达操作接⼝")
    @GetMapping("/transCompleted")
    public ResultVo transCompleted( int logGoodsOutId){
        return  logOutService.transCompleted(logGoodsOutId);
    }
    @ApiOperation("查找所有待出库的库品接⼝")
    @ApiImplicitParams({
            @ApiImplicitParam(dataType = "int",name = "pageNum", value =
                    "页号",required = true),
            @ApiImplicitParam(dataType = "int",name = "pageSize", value =
                    "每页数量",required = true),
            @ApiImplicitParam(dataType = "int",name = "logGoodsOutDepot", value =
                    "对应仓库",required = true)
    })
    @GetMapping("/findAllLogGoods")
    public ResultVo findAllLogGoods(@RequestParam(defaultValue = "1")int pageNum , @RequestParam(defaultValue = "8") int pageSize,String logGoodsOutDepot){
        return  logOutService.findAllNorOutGoods(pageNum,pageSize,logGoodsOutDepot);
    }

    /*
    管理员查找所有未出库库品
     */
    @ApiOperation("管理员查找所有待出库的库品接⼝")
    @ApiImplicitParams({
            @ApiImplicitParam(dataType = "int",name = "pageNum", value =
                    "页号",required = true),
            @ApiImplicitParam(dataType = "int",name = "pageSize", value =
                    "每页数量",required = true)
    })
    @GetMapping("/adminfindAllNorOutGoods")
    public ResultVo findAllLogGoods(@RequestParam(defaultValue = "1")int pageNum , @RequestParam(defaultValue = "8") int pageSize){
        return  logOutService.AdminfindAllNorOutGoods(pageNum,pageSize);
    }


    /*
    管理员查找所有已经出库库品
     */
    @ApiOperation("管理员查找所有已经出库的库品接⼝")
    @ApiImplicitParams({
            @ApiImplicitParam(dataType = "int",name = "pageNum", value =
                    "页号",required = true),
            @ApiImplicitParam(dataType = "int",name = "pageSize", value =
                    "每页数量",required = true)
    })
    @GetMapping("/adminfindAllOutGoods")
    public ResultVo findAllOutGoods(@RequestParam(defaultValue = "1")int pageNum , @RequestParam(defaultValue = "8") int pageSize){
        return  logOutService.AdminfindAllOutGoods(pageNum,pageSize);
    }
    /*
    根据仓库查找所有库品信息
     */
    @ApiOperation("根据仓库查找所有库品接⼝")
    @ApiImplicitParams({
            @ApiImplicitParam(dataType = "int",name = "pageNum", value =
                    "页号",required = true),
            @ApiImplicitParam(dataType = "int",name = "pageSize", value =
                    "每页数量",required = true),
            @ApiImplicitParam(dataType = "String",name = "logGoodsOutDepot", value =
                    "仓库",required = true)
    })
    @GetMapping("/findAllGoodsBydepot")
    public ResultVo findAllGoodsbydepot(@RequestParam(defaultValue = "1")int pageNum , @RequestParam(defaultValue = "8") int pageSize,String logGoodsOutDepot){
        return  logOutService.findAllGoodsByDepot(pageNum,pageSize,logGoodsOutDepot);
    }


}
